<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="../../css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" type="text/css" href="../../css/common.css" />
		<link rel="stylesheet" type="text/css" href="../../css/my/publish.css" />
	</head>

	<body>
		<div id="publish" v-cloak>
			<header class="mui-bar mui-bar-nav">
				<a class="mui-action-back mui-icon mui-icon-arrowleft mui-pull-left"></a>
				<h1 class="mui-title">我的发表</h1>
				<div class="mui-pull-right edit" @tap='isShowRemove = !isShowRemove' v-text="isShowRemove ? '完成' :'编辑'"></div>
			</header>
			<div id="pullrefresh" class="mui-content mui-scroll-wrapper">
				<div class="mui-scroll">
					<div class="publish_list" v-for="(list,index) in list">
						<div class="publish_img"><img v-lazy="imgCommonUrl + list.filePath" /></div>
						<div class="publish_data">
							<div class="publish_title">
								<span>{{list.title}}</span>
							</div>
							<div class="publish_time">
								{{list.issueDateStr}}
							</div>
							<div class="publish_num">
								<!--<div class="read">：666</div>-->
								<div class="pinglun">：{{list.proCount || 0}}</div>
								<div class="love">：{{list.addCount || 0}}</div>
							</div>
						</div>
						<div class="remove" :class="{show_remove : isShowRemove}" @tap="removeTap(list,index)">
							<button type="button" class="mui-btn mui-btn-danger">删除</button>
						</div>
					</div>
					<div></div>
				</div>
			</div>
			<div class="remove_alert" :class="{md_show : isRemove}">
				<div class=" md_content">
					<div class="alert_text">
						确定删除?
					</div>
					<div class="alert_button">
						<div @tap="isRemoveTap">
							确定
						</div>
						<div @tap="cancel">
							取消
						</div>
					</div>
				</div>
			</div>

			<div class="noshopp">
				<img src="../../images/noshop.png" alt="" />
				<div>暂无发表</div>
				
			</div>

		</div>
		<script src="../../js/mui.min.js"></script>
		<script src="../../js/libs/zepto.js"></script>
		<script src="../../js/libs/vue.js"></script>
		<script src="../../js/libs/vue-lazyload.js"></script>
		<script src="../../js/common.js"></script>
		<script type="text/javascript">
			mui.init({
				pullRefresh: {
					container: '#pullrefresh',
					up: {
						auto: true,
						contentrefresh: '正在加载...',
						callback: pullupRefresh
					}
				}
			});

			var mask = mui.createMask(hide);
			Vue.use(VueLazyload, {
				preLoad: 1.3,
				error: '../../images/noimg.jpg',
				loading: '../../images/noimg.jpg'
			});

			var publish = new Vue({
				el: '#publish',
				data: {
					imgCommonUrl: common.imageUrl,
					isRemove: false,
					pageNum: 1,
					list: [],
					isShowRemove: false,
					removeText: {}
				},
				methods: {
					removeTap: function(list, index) {
						this.removeText.id = list.themaId
						this.removeText.index = index
						this.isRemove = true
						mask.show()
					},
					//取消
					cancel: function() {
						mask.close()
					},
					//确定删除
					isRemoveTap: function() {
						if(!this.removeText) {
							return
						}
						common.ajax('/thematic/delete', {
							themaIds: publish.removeText.id
						}, function(data) {
							if(data.code == 1) {
								mask.close()
								plus.webview.getWebviewById('../special/specialregion.html').reload()
								publish.list.splice(publish.removeText.index, 1)
								publish.isRemove = false
								if(publish.list.length <= 0) {
									mui('#pullrefresh').pullRefresh().refresh(true);
									publish.pageNum = 1
									mui('#pullrefresh').pullRefresh().pullupLoading();
									mui('#pullrefresh').pullRefresh().scrollTo(0, 0, 0.1);
								}
							} else {
								if(data.resultMsg) {
									mui.toast(data.resultMsg)
								}
							}
						})
					}
				}
			})

			function pullupRefresh() {
				$(".noshopp").hide()
				$('.mui-pull-bottom-pocket').css('display', 'block !important')
				common.ajax('/thematic/getListByUser', {
					curPageNO: publish.pageNum++
				}, function(data) {
					if(data.code == 1) {
						console.log(data)
						if(publish.pageNum > data.data.pageCount) {
							mui('#pullrefresh').pullRefresh().endPullupToRefresh(true);
						} else {
							mui('#pullrefresh').pullRefresh().endPullupToRefresh();
						}
						publish.list = publish.list.concat(data.data.list)

						if(publish.list.length <= 0) {
							$(".noshopp").show()
							$('.mui-pull-bottom-pocket').css('display', 'none !important')
						} else {
							$(".noshopp").hide()
							$('.mui-pull-bottom-pocket').css('display', 'block !important')
						}
					} else {
						mui('#pullrefresh').pullRefresh().endPullupToRefresh();
						if(data.resultMsg) {
							mui.toast(data.resultMsg)
						}
					}
				}, true, 'get')

			}

			//			mask.show(); //显示遮罩
			//			mask.close();//关闭遮罩
			function hide() {
				publish.isRemove = false
			}
		</script>
	</body>

</html>